export default{
	//首页时间转换
	dateTime:function(date){
		let old = new Date(date);
		let now = new Date();
		//获取过去时间戳
		let d = old.getTime();
		let h = old.getHours();
		let m = old.getMinutes();
		let y = old.getFullYear();
		let M = old.getMonth()+1;
		let D = old.getDate();
		//获取现在时间戳
		let nd = now.getTime();
		let nh = now.getHours();
		let nm = now.getMinutes();
		let ny = now.getFullYear();
		let nM = now.getMonth()+1;
		let nD = now.getDate();
		
		//现在（三分钟内）
		if(D == nD && M == nM && y == ny && nm-m < 3){
			if(h<10){
				h = '0'+h;
			}
			if(m<10){
				m = '0'+m;
			}
			return '现在 '
		}
		//今天
		if(D == nD && M == nM && y == ny){
			if(h<10){
				h = '0'+h;
			}
			if(m<10){
				m = '0'+m;
			}
			return h+':'+m
		}
		//昨天
		if(D+1 == nD && M == nM && y == ny){
			if(h<10){
				h = '0'+h;
			}
			if(m<10){
				m = '0'+m;
			}
			return '昨天 '+h+':'+m
		}else{
			//大于两天
			return y+'/'+M+'/'+D
		}
	},
	
	//详细时间转换
	detailTime:function(nowdate){
		let now = new Date(nowdate);
		
		//获取现在时间戳
		let time = now.getTime();
		let hour = now.getHours();
		let min = now.getMinutes();
		let year = now.getFullYear();
		let month = now.getMonth()+1;
		let date = now.getDate();
		
		//处理时间
		if(month<10){
			month = '0'+month;
		}
		if(date<10){
			date= '0'+date;
		}
		if(hour<10){
			hour = '0'+hour;
		}
		if(min<10){
			min = '0'+min;
		}
		
		return year+'-'+month+'-'+date+' '+hour+':'+min
	},
	//时间间隔处理
	spaceTime: function(old,now){
		old = new Date(old);
		now = new Date(now);
		var time_o = old.getTime();
		var time_n = now.getTime();
		if((time_o+1000*60*5) < time_n){
			return old;
		}else{
			return '';
		}
	}
}